/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.diamondsys.embrapa;

import com.diamondsys.embrapa.util.JsfUtil;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Pablo
 */
@Entity
@Table(name = "tb_inst")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TbInst.findAll", query = "SELECT t FROM TbInst t ORDER BY t.nomFantasia ASC"),
    @NamedQuery(name = "TbInst.findByCodInstituicao", query = "SELECT t FROM TbInst t WHERE t.codInstituicao = :codInstituicao"),
    @NamedQuery(name = "TbInst.findByDesRazaosocial", query = "SELECT t FROM TbInst t WHERE t.desRazaosocial = :desRazaosocial"),
    @NamedQuery(name = "TbInst.findByNomFantasia", query = "SELECT t FROM TbInst t WHERE t.nomFantasia = :nomFantasia"),
    @NamedQuery(name = "TbInst.findByDesLideranca", query = "SELECT t FROM TbInst t WHERE t.desLideranca = :desLideranca"),
    @NamedQuery(name = "TbInst.findByDesEndereco", query = "SELECT t FROM TbInst t WHERE t.desEndereco = :desEndereco"),
    @NamedQuery(name = "TbInst.findByDesBairro", query = "SELECT t FROM TbInst t WHERE t.desBairro = :desBairro"),
    @NamedQuery(name = "TbInst.findByDesFone1", query = "SELECT t FROM TbInst t WHERE t.desFone1 = :desFone1"),
    @NamedQuery(name = "TbInst.findByDesFone2", query = "SELECT t FROM TbInst t WHERE t.desFone2 = :desFone2"),
    @NamedQuery(name = "TbInst.findByDesFone3", query = "SELECT t FROM TbInst t WHERE t.desFone3 = :desFone3"),
    @NamedQuery(name = "TbInst.findByDesFax", query = "SELECT t FROM TbInst t WHERE t.desFax = :desFax"),
    @NamedQuery(name = "TbInst.findByDesCxpostal", query = "SELECT t FROM TbInst t WHERE t.desCxpostal = :desCxpostal"),
    @NamedQuery(name = "TbInst.findByDesCep", query = "SELECT t FROM TbInst t WHERE t.desCep = :desCep"),
    @NamedQuery(name = "TbInst.findByDesCidade", query = "SELECT t FROM TbInst t WHERE t.desCidade = :desCidade"),
    @NamedQuery(name = "TbInst.findByDesUf", query = "SELECT t FROM TbInst t WHERE t.desUf = :desUf"),
    @NamedQuery(name = "TbInst.findByDesRegiao", query = "SELECT t FROM TbInst t WHERE t.desRegiao = :desRegiao"),
    @NamedQuery(name = "TbInst.findByDesCnpjCpf", query = "SELECT t FROM TbInst t WHERE t.desCnpjCpf = :desCnpjCpf"),
    @NamedQuery(name = "TbInst.findByDesInsEstadual", query = "SELECT t FROM TbInst t WHERE t.desInsEstadual = :desInsEstadual"),
    @NamedQuery(name = "TbInst.findByDesHomepage", query = "SELECT t FROM TbInst t WHERE t.desHomepage = :desHomepage"),
    @NamedQuery(name = "TbInst.findByDesEmail", query = "SELECT t FROM TbInst t WHERE t.desEmail = :desEmail"),
    @NamedQuery(name = "TbInst.findByDesTipInstituicao", query = "SELECT t FROM TbInst t WHERE t.desTipInstituicao = :desTipInstituicao"),
    @NamedQuery(name = "TbInst.findByDesRamo", query = "SELECT t FROM TbInst t WHERE t.desRamo = :desRamo"),
    @NamedQuery(name = "TbInst.findByDatAtualiz", query = "SELECT t FROM TbInst t WHERE t.datAtualiz = :datAtualiz"),
    @NamedQuery(name = "TbInst.findByDesSituacao", query = "SELECT t FROM TbInst t WHERE t.desSituacao = :desSituacao"),
    @NamedQuery(name = "TbInst.findByDesObsInst", query = "SELECT t FROM TbInst t WHERE t.desObsInst = :desObsInst"),
    @NamedQuery(name = "TbInst.findByDesNewsletter", query = "SELECT t FROM TbInst t WHERE t.desNewsletter = :desNewsletter"),
    @NamedQuery(name = "TbInst.findByDesPfPj", query = "SELECT t FROM TbInst t WHERE t.desPfPj = :desPfPj"),
    @NamedQuery(name = "TbInst.findByDesPais", query = "SELECT t FROM TbInst t WHERE t.desPais = :desPais"),
    @NamedQuery(name = "TbInst.findByDesAtivo", query = "SELECT t FROM TbInst t WHERE t.desAtivo = :desAtivo"),
    @NamedQuery(name = "TbInst.findByDesInadimplente", query = "SELECT t FROM TbInst t WHERE t.desInadimplente = :desInadimplente"),
    @NamedQuery(name = "TbInst.findByDesSenha", query = "SELECT t FROM TbInst t WHERE t.desSenha = :desSenha"),
    @NamedQuery(name = "TbInst.findByDatNascimentoFundacao", query = "SELECT t FROM TbInst t WHERE t.datNascimentoFundacao = :datNascimentoFundacao"),
    @NamedQuery(name = "TbInst.findByDesEstadocivil", query = "SELECT t FROM TbInst t WHERE t.desEstadocivil = :desEstadocivil"),
    @NamedQuery(name = "TbInst.findByDesSexo", query = "SELECT t FROM TbInst t WHERE t.desSexo = :desSexo"),
    @NamedQuery(name = "TbInst.findByInfoEmbrapa", query = "SELECT t FROM TbInst t WHERE t.infoEmbrapa = :infoEmbrapa"),
    @NamedQuery(name = "TbInst.findByDesPassaporte", query = "SELECT t FROM TbInst t WHERE t.desPassaporte = :desPassaporte"),
    @NamedQuery(name = "TbInst.findByDatInclusao", query = "SELECT t FROM TbInst t WHERE t.datInclusao = :datInclusao"),
    @NamedQuery(name = "TbInst.findByDesInclusao", query = "SELECT t FROM TbInst t WHERE t.desInclusao = :desInclusao"),
    @NamedQuery(name = "TbInst.findByDatAlteracao", query = "SELECT t FROM TbInst t WHERE t.datAlteracao = :datAlteracao"),
    @NamedQuery(name = "TbInst.findByDesAlteracao", query = "SELECT t FROM TbInst t WHERE t.desAlteracao = :desAlteracao")})
public class TbInst implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "cod_instituicao")
    private Integer codInstituicao;
    @Size(max = 100)
    @Column(name = "des_razaosocial")
    private String desRazaosocial;
    @Size(max = 50)
    @Column(name = "nom_fantasia")
    private String nomFantasia;
    @Column(name = "des_lideranca")
    private String desLideranca;
    @Size(max = 100)
    @Column(name = "des_endereco")
    private String desEndereco;
    @Size(max = 100)
    @Column(name = "des_bairro")
    private String desBairro;
    @Size(max = 20)
    @Column(name = "des_fone1")
    private String desFone1;
    @Size(max = 20)
    @Column(name = "des_fone2")
    private String desFone2;
    @Size(max = 100)
    @Column(name = "des_fone3")
    private String desFone3;
    @Size(max = 100)
    @Column(name = "des_fax")
    private String desFax;
    @Size(max = 30)
    @Column(name = "des_cxpostal")
    private String desCxpostal;
    @Size(max = 100)
    @Column(name = "des_cep")
    private String desCep;
    @Size(max = 10)
    @Column(name = "des_cidade")
    private String desCidade;
    @Size(max = 20)
    @Column(name = "des_uf")
    private String desUf;
    @Size(max = 100)
    @Column(name = "des_regiao")
    private String desRegiao;
    @Size(max = 45)
    @Column(name = "des_cnpj_cpf")
    private String desCnpjCpf;
    @Size(max = 25)
    @Column(name = "des_ins_estadual")
    private String desInsEstadual;
    @Size(max = 100)
    @Column(name = "des_homepage")
    private String desHomepage;
    @Size(max = 100)
    @Column(name = "des_email")
    private String desEmail;
    @Size(max = 50)
    @Column(name = "des_tip_instituicao")
    private String desTipInstituicao;
    @Size(max = 100)
    @Column(name = "des_ramo")
    private String desRamo;
    @Column(name = "dat_atualiz")
    @Temporal(TemporalType.DATE)
    private Date datAtualiz;
    @Size(max = 50)
    @Column(name = "des_situacao")
    private String desSituacao;
    @Size(max = 255)
    @Column(name = "des_obs_inst")
    private String desObsInst;
    @Size(max = 10)
    @Column(name = "des_newsletter")
    private String desNewsletter;
    @Size(max = 50)
    @Column(name = "des_pf_pj")
    private String desPfPj;
    @Size(max = 50)
    @Column(name = "des_pais")
    private String desPais;
    @Lob
    @Column(name = "des_logomarca")
    private byte[] desLogomarca;
    @Size(max = 10)
    @Column(name = "des_ativo")
    private String desAtivo;
    @Size(max = 10)
    @Column(name = "des_inadimplente")
    private String desInadimplente;
    @Size(max = 40)
    @Column(name = "des_senha")
    private String desSenha;
    @Column(name = "dat_nascimento_fundacao")
    @Temporal(TemporalType.DATE)
    private Date datNascimentoFundacao;
    @Size(max = 45)
    @Column(name = "des_estadocivil")
    private String desEstadocivil;
    @Size(max = 45)
    @Column(name = "des_sexo")
    private String desSexo;
    @Column(name = "info_embrapa")
    private Boolean infoEmbrapa;
    @Size(max = 45)
    @Column(name = "des_passaporte")
    private String desPassaporte;
    @Column(name = "dat_inclusao")
    @Temporal(TemporalType.TIMESTAMP)
    private Date datInclusao;
    @Size(max = 45)
    @Column(name = "des_inclusao")
    private String desInclusao;
    @Column(name = "dat_alteracao")
    @Temporal(TemporalType.TIMESTAMP)
    private Date datAlteracao;
    @Size(max = 45)
    @Column(name = "des_alteracao")
    private String desAlteracao;
    @ManyToMany(mappedBy = "tbInstList")
    private List<SigifEventosint> sigifEventosintList;
    @ManyToMany(mappedBy = "tbInstList")
    private List<Interesses> interessesList;
    @ManyToMany(mappedBy = "tbInstList")
    private List<Sistemas> sistemasList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tbInstCodInstituicao")
    private List<Sac> sacList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tbInstCodInstituicao")
    private List<Visitas> visitasList;
    @JoinColumn(name = "subcategoria_id", referencedColumnName = "id")
    @ManyToOne
    private Subcategoria subcategoriaId;
    @JoinColumn(name = "profissao_profissao_id", referencedColumnName = "id")
    @ManyToOne
    private ProfissaoFormacao profissaoProfissaoId;
    @JoinColumn(name = "profissao_formacao_id", referencedColumnName = "id")
    @ManyToOne
    private ProfissaoFormacao profissaoFormacaoId;
    @JoinColumn(name = "cargo_id", referencedColumnName = "id")
    @ManyToOne
    private Cargo cargoId;

    public TbInst() {
    }

    public TbInst(Integer codInstituicao) {
        this.codInstituicao = codInstituicao;
    }

    public Integer getCodInstituicao() {
        return codInstituicao;
    }

    public void setCodInstituicao(Integer codInstituicao) {
        this.codInstituicao = codInstituicao;
    }

    public String getDesRazaosocial() {
        return desRazaosocial;
    }

    public void setDesRazaosocial(String desRazaosocial) {
        this.desRazaosocial = desRazaosocial;
    }

    public String getNomFantasia() {
        return nomFantasia;
    }

    public void setNomFantasia(String nomFantasia) {
        this.nomFantasia = nomFantasia;
    }

    public String getDesLideranca() {
        return desLideranca;
    }

    public void setDesLideranca(String desLideranca) {
        this.desLideranca = desLideranca;
    }
    
    public String getDesEndereco() {
        return desEndereco;
    }

    public void setDesEndereco(String desEndereco) {
        this.desEndereco = desEndereco;
    }

    public String getDesBairro() {
        return desBairro;
    }

    public void setDesBairro(String desBairro) {
        this.desBairro = desBairro;
    }

    public String getDesFone1() {
        return JsfUtil.formatPhone(desFone1);
    }

    public void setDesFone1(String desFone1) {
        this.desFone1 = JsfUtil.formatPhone(desFone1);
    }

    public String getDesFone2() {
        return JsfUtil.formatPhone(desFone2);
    }

    public void setDesFone2(String desFone2) {
        this.desFone2 = JsfUtil.formatPhone(desFone2);
    }

    public String getDesFone3() {
        return desFone3;
    }

    public void setDesFone3(String desFone3) {
        this.desFone3 = desFone3;
    }

    public String getDesFax() {
        return JsfUtil.formatPhone(desFax);
    }

    public void setDesFax(String desFax) {
        this.desFax = JsfUtil.formatPhone(desFax);
    }

    public String getDesCxpostal() {
        return JsfUtil.formatCep(desCxpostal);
    }

    public void setDesCxpostal(String desCxpostal) {
        this.desCxpostal = JsfUtil.formatCep(desCxpostal);
    }

    public String getDesCep() {
        return desCep;
    }

    public void setDesCep(String desCep) {
        this.desCep = desCep;
    }

    public String getDesCidade() {
        return desCidade;
    }

    public void setDesCidade(String desCidade) {
        this.desCidade = desCidade;
    }

    public String getDesUf() {
        return desUf;
    }

    public void setDesUf(String desUf) {
        this.desUf = desUf;
    }

    public String getDesRegiao() {
        return desRegiao;
    }

    public void setDesRegiao(String desRegiao) {
        this.desRegiao = desRegiao;
    }

    public String getDesCnpjCpf() {
        return desCnpjCpf;
    }

    public void setDesCnpjCpf(String desCnpjCpf) {
        this.desCnpjCpf = desCnpjCpf;
    }

    public String getDesInsEstadual() {
        return desInsEstadual;
    }

    public void setDesInsEstadual(String desInsEstadual) {
        this.desInsEstadual = desInsEstadual;
    }

    public String getDesHomepage() {
        return desHomepage;
    }

    public void setDesHomepage(String desHomepage) {
        this.desHomepage = desHomepage;
    }

    public String getDesEmail() {
        return desEmail;
    }

    public void setDesEmail(String desEmail) {
        this.desEmail = desEmail;
    }

    public String getDesTipInstituicao() {
        return desTipInstituicao;
    }

    public void setDesTipInstituicao(String desTipInstituicao) {
        this.desTipInstituicao = desTipInstituicao;
    }

    public String getDesRamo() {
        return desRamo;
    }

    public void setDesRamo(String desRamo) {
        this.desRamo = desRamo;
    }

    public Date getDatAtualiz() {
        return datAtualiz;
    }

    public void setDatAtualiz(Date datAtualiz) {
        this.datAtualiz = datAtualiz;
    }

    public String getDesSituacao() {
        return desSituacao;
    }

    public void setDesSituacao(String desSituacao) {
        this.desSituacao = desSituacao;
    }

    public String getDesObsInst() {
        return desObsInst;
    }

    public void setDesObsInst(String desObsInst) {
        this.desObsInst = desObsInst;
    }


    public String getDesNewsletter() {
        return desNewsletter;
    }

    public void setDesNewsletter(String desNewsletter) {
        this.desNewsletter = desNewsletter;
    }

    public String getDesPfPj() {
        return desPfPj;
    }

    public void setDesPfPj(String desPfPj) {
        this.desPfPj = desPfPj;
    }

    public String getDesPais() {
        return desPais;
    }

    public void setDesPais(String desPais) {
        this.desPais = desPais;
    }

    public byte[] getDesLogomarca() {
        return desLogomarca;
    }

    public void setDesLogomarca(byte[] desLogomarca) {
        this.desLogomarca = desLogomarca;
    }

    public String getDesAtivo() {
        return desAtivo;
    }

    public void setDesAtivo(String desAtivo) {
        this.desAtivo = desAtivo;
    }

    public String getDesInadimplente() {
        return desInadimplente;
    }

    public void setDesInadimplente(String desInadimplente) {
        this.desInadimplente = desInadimplente;
    }

    public String getDesSenha() {
        return desSenha;
    }

    public void setDesSenha(String desSenha) {
        this.desSenha = desSenha;
    }

    public Date getDatNascimentoFundacao() {
        return datNascimentoFundacao;
    }

    public void setDatNascimentoFundacao(Date datNascimentoFundacao) {
        this.datNascimentoFundacao = datNascimentoFundacao;
    }

    public String getDesEstadocivil() {
        return desEstadocivil;
    }

    public void setDesEstadocivil(String desEstadocivil) {
        this.desEstadocivil = desEstadocivil;
    }

    public String getDesSexo() {
        return desSexo;
    }

    public void setDesSexo(String desSexo) {
        this.desSexo = desSexo;
    }

    public Boolean getInfoEmbrapa() {
        return infoEmbrapa;
    }

    public void setInfoEmbrapa(Boolean infoEmbrapa) {
        this.infoEmbrapa = infoEmbrapa;
    }

    public String getDesPassaporte() {
        return desPassaporte;
    }

    public void setDesPassaporte(String desPassaporte) {
        this.desPassaporte = desPassaporte;
    }

    public Date getDatInclusao() {
        
        return datInclusao;
    }

    public void setDatInclusao(Date datInclusao) {
        this.datInclusao = datInclusao;
    }

    public String getDesInclusao() {
        return desInclusao;
    }

    public void setDesInclusao(String desInclusao) {
        this.desInclusao = desInclusao;
    }

    public Date getDatAlteracao() {
        return datAlteracao;
    }

    public void setDatAlteracao(Date datAlteracao) {
        this.datAlteracao = datAlteracao;
    }

    public String getDesAlteracao() {
        return desAlteracao;
    }

    public void setDesAlteracao(String desAlteracao) {
        this.desAlteracao = desAlteracao;
    }

    @XmlTransient
    public List<SigifEventosint> getSigifEventosintList() {
        return sigifEventosintList;
    }

    public void setSigifEventosintList(List<SigifEventosint> sigifEventosintList) {
        this.sigifEventosintList = sigifEventosintList;
    }

    @XmlTransient
    public List<Interesses> getInteressesList() {
        return interessesList;
    }

    public void setInteressesList(List<Interesses> interessesList) {
        this.interessesList = interessesList;
    }

    @XmlTransient
    public List<Sistemas> getSistemasList() {
        return sistemasList;
    }

    public void setSistemasList(List<Sistemas> sistemasList) {
        this.sistemasList = sistemasList;
    }

    @XmlTransient
    public List<Sac> getSacList() {
        return sacList;
    }

    public void setSacList(List<Sac> sacList) {
        this.sacList = sacList;
    }

    @XmlTransient
    public List<Visitas> getVisitasList() {
        return visitasList;
    }

    public void setVisitasList(List<Visitas> visitasList) {
        this.visitasList = visitasList;
    }

    public Subcategoria getSubcategoriaId() {
        return subcategoriaId;
    }

    public void setSubcategoriaId(Subcategoria subcategoriaId) {
        this.subcategoriaId = subcategoriaId;
    }

    public ProfissaoFormacao getProfissaoProfissaoId() {
        return profissaoProfissaoId;
    }

    public void setProfissaoProfissaoId(ProfissaoFormacao profissaoProfissaoId) {
        this.profissaoProfissaoId = profissaoProfissaoId;
    }

    public ProfissaoFormacao getProfissaoFormacaoId() {
        return profissaoFormacaoId;
    }

    public void setProfissaoFormacaoId(ProfissaoFormacao profissaoFormacaoId) {
        this.profissaoFormacaoId = profissaoFormacaoId;
    }

    public Cargo getCargoId() {
        return cargoId;
    }

    public void setCargoId(Cargo cargoId) {
        this.cargoId = cargoId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codInstituicao != null ? codInstituicao.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TbInst)) {
            return false;
        }
        TbInst other = (TbInst) object;
        if ((this.codInstituicao == null && other.codInstituicao != null) || (this.codInstituicao != null && !this.codInstituicao.equals(other.codInstituicao))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.diamondsys.embrapa.TbInst[ codInstituicao=" + codInstituicao + " ]";
    }
    
}
